package Training.Threadtest01;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Threadmain {
    public static void main(String[] args) {
//        Thread01Thread thread01 = new Thread01Thread();
//        thread01.start();
//        for (int i = 0; i < 100; i++) {
//            System.out.println("主线程:" + i);
//        }
//        Thread02Runnable thread02 = new Thread02Runnable();
//        Thread thread = new Thread(thread02);
//        thread.start();
//        Thread03callable thread03 = new Thread03callable();
//        FutureTask<String> stringFutureTask = new FutureTask<>(thread03);
//        Thread thread = new Thread(stringFutureTask);
//        thread.start();
//        try {
//            String result = stringFutureTask.get();
//            System.out.println(result);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        } catch (ExecutionException e) {
//            throw new RuntimeException(e);
//        }
//        for (int i = 0; i < 100; i++) {
//            System.out.println("mainthread"+i);
//        }
        //匿名内部类
//        new Thread(new Runnable(){
//            @Override
//            public void run() {
//                for (int i = 0; i < 100; i++) {
//                    System.out.println("匿名内部类子线程:" + i);
//                }
//            }
//        }).start();
        //使用lambda表达式
//        new Thread(()->{
//            for (int i = 0; i < 100; i++) {
//                System.out.println("Lambda:" + i);
//            }
//        }).start();
//        ThreadTickets01 threadTickets01 = new ThreadTickets01();
//        ThreadTickets01 threadTickets011 = new ThreadTickets01();
    }
}
